<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<% 
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script>
var sendMessage2Allws = null;
if('WebSocket' in window){
	sendMessage2Allws = new WebSocket("ws://<%=request.getServerName()%>:<%=request.getServerPort()%>/websocket/sendMessage2Allws");
}else {
	alert('不支持');
}
var sendMassage = function(){
	var msg = document.getElementById('msg').value;
	websocket.send(msg);
}
websocket.onmessage = function (event) {
	document.getElementById('msg-box').innerHTML = document.getElementById('msg-box').innerHTML + event.data + '<br/>';
}
</script>
</head>
<body>
请输入内容：<input type="text" id="msg"/> 
<button onclick="sendMassage();">发送</button>
<hr/>
<div id="msg-box"></div>
</body>
</html>